import os
from pathlib import Path

from django.conf import settings
from django.http import HttpResponse
from django.shortcuts import render

# Create your views here.
def favicon(request):
    #返回图标
    temp = settings.TEMPLATES[0]["DIRS"][0]
    dataPath = os.path.join(temp, "favicon.ico")
    if Path(dataPath).is_file():
        with open(dataPath, 'rb') as file:
            response = HttpResponse(file.read())
    else:
        response = HttpResponse("YES")
    return response